<template>
  <el-dialog :visible.sync="show" title="选择产品" width="70%" @close="closeDialog">
      <el-form inline>
          <el-form-item>
              <el-input v-model="where.fDeviceModel" placeholder="请输入查询内容"></el-input>
          </el-form-item>
          <el-form-item>
              <el-button type="primary">查询</el-button>
          </el-form-item>
      </el-form>
      <el-table :data="tableData" style="width: 100%" @row-click="checkProduct">
          <el-table-column label="选择" width="50">
              <template slot-scope="scope">
                  <el-radio :value="checkData.fId" :label="scope.row.fId"></el-radio>
              </template>
          </el-table-column>  
          <el-table-column prop="fProductName" label="产品名称"></el-table-column>
          <el-table-column prop="fDeviceModel" label="产品型号"></el-table-column>
          <el-table-column prop="fProductSize" label="尺寸"></el-table-column>
          <el-table-column prop="fModuleType" label="模组类型"></el-table-column>
          <el-table-column prop="fIcChip" label="IC芯片"></el-table-column>
          <el-table-column prop="fRemark" label="备注信息"></el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="where.pageNum" :limit.sync="where.pageSize" @pagination="getList" />
      <div slot="footer" class="dialog-footer">
          <el-button @click="show = false">取 消</el-button>
          <el-button type="primary" @click="toSure">确认</el-button>
      </div>
  </el-dialog>
</template>

<script>
import {listProduct} from '@/api/basicData/product'
export default {
  name: 'product',
  data() {
      return {
          show: false,
          where: {
              pageNum: 1,
              pageSize: 10,
              fDeviceModel: ''
          },
          tableData: [],
          total: 0,
          checkData: {
              fId: ''
          }
      }
  },
  methods: {
      open() {
          this.show = true
          this.getList()
      },
      closeDialog(){
          this.tableData = []
          this.where.pageNum = 1
          this.where.fDeviceModel = ''
      },
      getList() {
          listProduct(this.where).then(res=>{
              this.tableData = res.rows
              this.total = res.total
          })
      },
      checkProduct(row) {
          this.checkData = row
      },
      toSure() {
          this.show = false
          this.$emit("sure",this.checkData)
      }
  }
}
</script>

<style lang="scss" scoped>

::v-deep .el-radio__label {
  display: none;
}
</style>